
<?php //TODO : Factoriser les select ?>
<form action="index.php" name="gothere" class="nabioForm">
<input value="on" name="a" type="hidden"/>
<h3 class="titreForm"><?php echo $menu['a']['desc']?></h3>
	<table summary="Fields to search" id="aForm">
		<?php
		foreach($select as $key=>$value){
			// Nouvelle requête
			if (empty($_GET['a'])){
				echo '<tr><td>'.$value.'&nbsp;:&nbsp;</td><td>';
				// Ajout de la date de fin
				if ($key=='yrvol'){
					echo ' Début ';
					echo '<select name="yrvol" class="inputbox">'."\n";
					echo '<option value="">&nbsp;'."</option>\n";
					foreach($$value as $value2){
						if(!empty($value2[0])){
							echo '<option value="'.$value2[0].'">'.$value2[0]."</option>\n";
						}
					}
					echo '</select>';
					echo ' Fin ';
					echo '<select name="yrvolEnd">'."\n";
					echo '<option value="">&nbsp;'."</option>\n";
					foreach($$value as $value2){
						if(!empty($value2[0])){
							echo '<option value="'.$value2[0].'">'.$value2[0]."</option>\n";
						}
					}
					echo '</select>';
				}
				else {
					echo '<select name="'.$key.'" class="inputbox">'."\n";
					echo '<option value="">&nbsp;'."</option>\n";
					foreach($$value as $value2){
						if(!empty($value2[0])){
							echo '<option value="'.$value2[0].'">'.$value2[0]."</option>\n";
						}
					}
					echo '</select>';
				}
				echo '</td></tr>'."\n";
			}
			// Réponse à une requête
			else {
				if (!empty($_GET[$key])){
					echo '<tr><td>'.$value.'&nbsp;:&nbsp;</td><td>';
				// Ajout de la date de fin
				if ($key=='yrvol'){
					// Message en cas de date non valide
					if (!empty($_GET['yrvolEnd'])) if ($_GET['yrvolEnd'] < $_GET['yrvol']) echo '<div style="color:red;margin-bottom:0.5em;">La date de Fin est inférieure à la date de Début !<br/>Modifiez votre requête :</div>';
					echo ' Début ';
					echo '<select name="yrvol" class="inputbox">'."\n";
					echo '<option value="">&nbsp;'."</option>\n";
					foreach($$value as $value2){
						if(!empty($value2[0])){
							echo '<option value="'.$value2[0].'" ';
							if(isset($_GET[$key]) and $_GET[$key]==$value2[0]) echo 'selected="selected"';
							echo '>'.$value2[0]."</option>\n";
						}
					}
					echo '</select>';
					echo ' Fin ';
					echo '<select name="yrvolEnd" class="inputbox">'."\n";
					echo '<option value="">&nbsp;'."</option>\n";
					foreach($$value as $value2){
						if(!empty($value2[0])){
							echo '<option value="'.$value2[0].'" ';
							if(isset($_GET['yrvolEnd']) and $_GET['yrvolEnd']==$value2[0]) echo 'selected="selected"';
							echo '>'.$value2[0]."</option>\n";
						}
					}
					echo '</select>';
				}
				else {
					echo '<select name="'.$key.'" class="inputbox">'."\n";
					echo '<option value="">&nbsp;'."</option>\n";
					foreach($$value as $value2){
						if(!empty($value2[0])){
							echo '<option value="'.$value2[0].'" ';
							if(isset($_GET[$key]) and $_GET[$key]==$value2[0]) echo 'selected="selected"';
							echo '>'.$value2[0]."</option>\n";
						}
					}
					echo '</select>';
				}
				echo '</td></tr>'."\n";
				}
			}
		}
		?>
		<tr><td></td><td>
			<input value="Go" class="bouton" type="submit" name="action"/>
			<?php if (!empty($_GET['a'])) echo '<span style="margin-left:1em;"><a href="?a">Nouvelle recherche avancée</a></span>'; ?>
		</td></tr>
	</table>
</form>
<?php if(!empty($_GET['a'])) include('../templates/'.$template.'/resNumber.php'); ?>